const fieldList = [ // 新增弹出数据
  { label: '父级模块', value: 'pid', type: 'select', option: 'sysModule',  loading: true, remote:true, store:"dictSrv/sysModule", width: '300px'},
  { label: '模块名称', value: 'title', type: 'input', width: '300px' },
  { label: '模块界面', value: 'page', type: 'input', width: '300px' },
  { label: '授权地址', value: 'api', type: 'input', width: '300px' },
  { label: '模块备注', value: 'memo', type: 'input', width: '300px' },
  { label: '模块图标', value: 'icon', type: 'input', width: '300px' },
  { label: '模块排序', value: 'rank', type: 'number', width: '300px' },
  { label: '是否显示', value: 'ishow', type: 'select', width: '200px', option: 'yesOrNo', filterable: true},
  { label: '是否默认', value: 'isdefault', type: 'select', width: '200px', option: 'yesOrNo', filterable: true},
  { label: '是否禁用', value: 'status', type: 'select', width: '200px', option: 'sysRoleStatus', filterable: true},
  { label: '系统模块', value: 'issys', type: 'select', width: '200px', option: 'yesOrNo', filterable: true}
]
const tables = [ // 表格数据
  { label: '模块名称', value: 'title', minwidth:200},
  { label: '流水编号', value: 'id', width:80},
  { label: '模块界面', value: 'page',minwidth:140 },
  { label: '授权地址',  value: 'api', minwidth:140},
  { label: '是否禁用', value: 'status', type: 'slot', width:80},
  { label: '是否显示', value: 'ishow', type: 'slot',  width:80},
  { label: '系统模块',  width:80, type: 'slot', value: 'issys'},
  { label: '模块描述',  value: 'memo'},
  { label: '操作', type: 'slot', value: 'btn', width:220}
];
const rules = {
	title: [{ required: true, message: '模块名称', trigger: 'change' }],
	page: [{ required: true, message: '模块界面', trigger: 'change' }],
    ishow: [{ required: true, message: '是否显示', trigger: 'change' }],
    issys: [{ required: true, message: '系统模块', trigger: 'change' }],
    status: [{ required: true, message: '是否禁用', trigger: 'change' }],
    isdefault: [{ required: true, message: '是否默认', trigger: 'change' }],
    memo: [{ required: true, message: '模块备注', trigger: 'change' }]
}

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data && data[ckey])? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  fieldList,rules,fieldData,tables
}
